<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue.set</title>
    <script type="text/javascript" src="../assets/js/vue-2.3.0.js"></script>
</head>
<body>
    <h1>vue.set 全局操作</h1>
    <hr>
    <div id="app">
        {{num}}
        <ul>
            <li v-for=" aa in arr">{{aa}}</li>
        </ul>
    </div>
    <button onclick="add()">添加</button>
    <button onclick="add2()">改变</button>
</body>
<script type="text/javascript">
    let outData={
        num:1,
        arr:['aaa','bbb','ccc']
    }
    function add(){
        // Vue.set(outData,"num",3);
        // app.num++;
        outData.num++;
    }
    function add2(){
        console.log("我已经执行了");
        // app.arr[1]='ddd';   //无效
        Vue.set(app.arr,2,'ddd');//有效
    }
    var app = new Vue({
        el:'#app',
        data: outData
    })
</script>
</html>